VERSION 0.6
FROM golang:1.21.3

build:
  WORKDIR /build
  RUN apt install -y git
  RUN apt install -y binutils
  COPY go.mod .
  COPY *.go .
  COPY admin_api_serv admin_api_serv
  COPY api_common api_common
  COPY api_serv api_serv
  COPY bg_runner bg_runner
  COPY config config
  COPY dao dao
  COPY metric_serv metric_serv
  COPY mail_serv mail_serv
  COPY notice_serv notice_serv
  COPY utils utils
  COPY upgrade upgrade
  COPY triger_impl triger_impl
  RUN go env -w GOPRIVATE="gitee.com,jihulab.com,atomgit.com"
  RUN go env -w GOPROXY="https://goproxy.cn,direct"
  RUN go mod tidy
  RUN go build -o server
  RUN strip server
  SAVE ARTIFACT server

docker:
  FROM ubuntu
  ARG TAG="latest"
  WORKDIR /app
  RUN apt update
  RUN apt install -y ca-certificates
  COPY +build/server .
  COPY server.yaml .
  ENTRYPOINT /app/server /app/server.yaml
  SAVE IMAGE --push ccr.ccs.tencentyun.com/linksaas/api-server:$TAG 
